OOP  - Assignment 2

Topic:              Savings Account

Points:             25

Due:                1-28-2000

Instructor:             Dana Steil

 


Expected review Material:

  1. Class definition
  2. Object instantiation
  3. Private vs. Public members and functions
  4. Console IO and IO manipulation
  5. Use of constants
  6. Good variable and function names
  7. Case insensitive character comparison
  8. Default arguments
  9. Function overloading

Expected new material:

  1. Overloading constructors
  2. Default arguments with constructors
  3. Utility functions
  4. Access functions
  5. Static member variables
  6. Compiler directives
  7. Avoiding returning a non-const pointer to a private data member
  8. Member Initializers

 


 

General Overview:

You will be creating a class to represent a simple savings account with a few data members and functions. 

 

CSavings Header File:            SavingsAccount.h

 

#ifndef SAVINGS_ACCOUNT_H

#define SAVINGS_ACCOUNT_H

 

const int MAX_OWNER_LENGTH = 30;

 

class CSavingsAccount

{

       public:

              CSavingsAccount(const char* Owner, 

                       const double MinimumBalance,

                             const double InitialBalance = 0);

 

              double Balance();

              static double AnnualInterestRate();

              const char* Owner();

              void CalculateMonthlyInterest();

              void DepositFunds(const double Amount);

              void WithdrawFunds(const double Amount, bool& Success);

 

              static UpdateInterestRate(const double NewAnnualInterestRate);

       private:

              static const int TIMES_INTEREST_PAID_PER_YEAR;

              static const int MAX_INTEREST_RATE;

              static const int MIN_INTEREST_RATE;

              const double MINIMUM_BALANCE;

 

              double m_Balance;

              char m_Owner[MAX_OWNER_LENGTH];

              static double m_AnnualInterestRate;

             

              bool ValidBalance( const double Balance);

              static bool ValidInetestRate(const double InterestRate);

};

 

 

#endif

CSavings Method Details: (20 Points)

            Filename: SavingsAccount.cpp

           

            Be sure each of the following functions are used.

CSavingsAccount(const char* Owner,  const double MinimumBalance,

const double InitialBalance = 0);  - For a savings account to be created an owner and minimum balance are required.

            double Balance(); - Returns the balance of the savings account.

           

static double AnnualInterestRate(); - Returns the AnnualInterestRate.

           

const char* Owner(); - Returns a pointer to the Owner.

 

void CalculateMonthlyInterest(); - Calculates the monthly interest by multiplying the balance by the annual interest rate and then dividing that amount by the TIMES_INTEEST_PAID_PER_YEAR.

 

void DepositFunds(const double Amount); - adds the argument amount to the balance

 

void WithdrawFunds(const double Amount, bool& Success); - subtracts the argument amount from the balance.  Check to make sure that the balance does not become negative.  If the withdraw amount is greater than the balance do not remove any funds and set the Success flag to false.

 

static UpdateInterestRate(const double NewAnnualInterestRate, bool& Success); - Updates the interest rate.  Checks to make sure the new interest rate is valid, if it is not the interest rate remains the same and the Success flag is set to false.

                       

bool ValidBalance( const double Balance); - Utility function that returns true if the Balance is greater than or equal to the MIN_BALANCE, false otherwise.

 

static bool ValidInterestRate(const double InterestRate); - Utility function that returns true if the Interest rate is greater than or equal to the MIN_INTEREST_RATE and less than or equal to the MAX_INTEREST_RATE, false otherwise. 

 

Test Program:            (5 points)

 

            Filename: Assignment2.cpp

 

            Write a test program that will:

1.      Create multiple Savings Accounts using the each of its possible constructors.

2.      Test each of the public member functions using the objects created above.

 

Each students test program may very.  Part of your grade will reflect the thoroughness of your test program.